home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group01a.txt
/
000072_icon-group-sender _Tue Jun 27 16:59:29 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2002-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id QAA21185
for icon-group-addresses; Tue, 27 Jun 2000 16:59:18 -0700 (MST)
Message-Id: <200006272359.QAA21185@baskerville.CS.Arizona.EDU>
Date: Tue, 27 Jun 2000 16:38:22 -0400
From: "Steve Graham" <Steve_Graham@labcorp.com>
To: <icon-group@optima.CS.Arizona.EDU>
Subject: Re: Permutations/Combinations
Content-Disposition: inline
X-MIME-Autoconverted: from quoted-printable to 8bit by baskerville.CS.Arizona.EDU id NAA15678
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 1544
Gregg,
That's exactly what I was looking for. Now, let me have some time to ponder why it works...
---------------------------------------------------------------------------------------
Steve Graham
Senior Programmer/Analyst
LabCorp
Phone: (972) 437-5255, ext 5224
Fax: (972) 454-1040
Mail: grahams@labcorp.com
---------------------------------------------------------------------------------------
>>> Gregg Townsend <gmt@baskerville.CS.Arizona.EDU> 06/27/00 03:08PM >>>
From: "Steve Graham" <Steve_Graham@labcorp.com>
Although I do not know how to utilize Icon's built-in features to generate
all possible combinations/permutations (which one is it?) where the letters
appear once and only once, I do believe that, given the generated list, I
will recognize the valid words. And I'm sure that Icon can EASILY produce
the list, whether the algorthim utilizes reversible assignment or not.
Can someone show me how?
The Icon program library contains a nice little permutation generator
(in the procs/strings.icn file):
procedure permute(s)
local i
if *s = 0 then return ""
suspend s[i := 1 to *s] || permute(s[1:i] || s[i+1:0])
end
So to generate all 720 permutations you'd just do this:
procedure main()
every write(permute("abelmr"))
end
---------------------------------------------------------------------------
Gregg Townsend Staff Scientist The University of Arizona
gmt@cs.arizona.edu Computer Science Tucson, Arizona, USA